#ifndef BUFFERCONSTANTS_H
#define BUFFERCONSTANTS_H

#pragma once

#include "ToolkitLayer.h"
#include <map>

#if defined (__APPLE__)
	#include <ext/hash_map>
	namespace HASH_MAP_EXTENSION = __gnu_cxx;
#elif defined (_WIN32)
	#include <hash_map>
	namespace HASH_MAP_EXTENSION = stdext;
#else
	#include <hash_map>
	namespace HASH_MAP_EXTENSION = std;	
#endif



/**
 * This class provides a set of dictionaries for the values used as type
 * identifiers for buffers and events. The dictionaries consist in maps between
 * string descriptions and identifier values.
 *
 * Since the same maps should be used by different objects, this class is
 * implemented as a singleton.
 *
 * @author Fabricio Anastacio - fabriciocfa@yahoo.com
 * @since July 24, 2007
 */
class TOOLKITLAYER_API ConstantProvider
{
	// Attributes
private:
	/** Singleton instance of this class. */
	static ConstantProvider* instance;

	/** Dictionary of buffer types (provides a map between a name and the
	 * identifier of a buffer type). */
	std::map<std::string, unsigned int> bufferTypes;
	//HASH_MAP_EXTENSION::hash_map<char*, unsigned int> bufferTypes;
	/** Keeps the value that can be used for the next buffer type identifier. */
	unsigned int nextBufferType;

	/** Dictionary of button buffer values (provides a map between a name and the
	 * value of a button buffer entry). */
	std::map<std::string, unsigned int> buttonBufferValues;
	//HASH_MAP_EXTENSION::hash_map<char*, unsigned int> buttonBufferValues;
	/** Keeps the value that can be used for the next button buffer value. */
	unsigned int nextButtonBufferValue;

	/** Dictionary of event type values (provides a map between a name and the
	 * identifier of an event type). */
	std::map<std::string, unsigned int> eventTypes;
	//HASH_MAP_EXTENSION::hash_map<char*, unsigned int> eventTypes;
	/** Keeps the value that can be used for the next event type identifier. */
	unsigned int nextEventType;


	// Methods
protected:
	/**
	 * Constructs an instance of this class.
	 */
	ConstantProvider(void);

public:
	/**
	 * Provides access to the singleton instance of this class.
	 */
	static ConstantProvider* getInstance();
	/**
	 * Destroys this class.
	 */
	~ConstantProvider(void);

	/**
	 * Returns the buffer type identifier for the given string description of
	 * the type. If no entry is matched to the given description, a new entry
	 * is created assigning a unused identifier to it. The description matching
	 * is case sensitive.
	 *
	 * @return the buffer type identifier for the given string description of
	 * the type.
	 */
	unsigned int getBufferTypeIdentifier(std::string description);

	/**
	 * Returns the button buffer value for the given string description. If no
	 * entry is matched to the given description, a new entry is created
	 * assigning a unused value to it. The description matching is case sensitive.
	 *
	 * @return the button buffer value for the given string description.
	 */
	unsigned int getButtonBufferValue(std::string description);

	/**
	 * Returns the event type identifier for the given string description of
	 * the type. If no entry is matched to the given description, a new entry
	 * is created assigning a unused identifier to it. The description matching
	 * is case sensitive.
	 *
	 * @return the event type identifier for the given string description of
	 * the type.
	 */
	unsigned int getEventTypeIdentifier(std::string description);
};

#endif // BUFFERCONSTANTS_H
